/*
自己选择的路 ,跪着也要走完。朋友们 , 虽然这个世界日益浮躁起来,只
要能够为了当时纯粹的梦想和感动坚持努力下去 , 不管其它人怎么样,我
们也能够保持自己的本色走下去。
To the world , you will be a person , but to a person , you
will be the world .                               ——AKPower
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const ll maxn = 2e5 + 100;
struct node
{
    ll l, r, sum;
} hjt[maxn * 40];
ll root[maxn], tot;
ll n, m;
vector<ll> v;
ll a[maxn];

ll getid(ll num)
{
    return lower_bound(v.begin(), v.end(), num) - v.begin() + 1;
}

void insert(ll l, ll r, ll pre, ll &now, ll p)
{
    now = ++tot;
    hjt[now] = hjt[pre];
    hjt[now].sum++;
    if (l == r)
        return;
    ll mid = (l + r) >> 1;
    if (p <= mid)
    {
        insert(l, mid, hjt[pre].l, hjt[now].l, p);
    }
    else
        insert(mid + 1, r, hjt[pre].r, hjt[now].r, p);
    return;
}

// void del(ll l, ll r, ll pre, ll &now, ll p)
// {
//     now = ++tot;
//     hjt[now] = hjt[pre];
//     hjt[now].sum++;
//     if (l == r)
//         return;
//     ll mid = (l + r) >> 1;
//     if (p <= mid)
//     {
//         insert(l, mid, hjt[pre].l, hjt[now].l, p);
//     }
//     else
//         insert(mid + 1, r, hjt[pre].r, hjt[now].r, p);
//     return;
// }

ll query(ll l, ll r, ll L, ll R, ll k)
{
    if (l == r)
        return l;
    ll sum = hjt[hjt[R].l].sum - hjt[hjt[L].l].sum;
    if (k <= sum)
    {
        return query(l, (l + r) >> 1, hjt[L].l, hjt[R].l, k);
    }
    else
        return query(((l + r) >> 1) + 1, r, hjt[L].r, hjt[R].r, k - sum);
}

int main()
{
    IOS;
    cin >> n >> m;
    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i];
        v.push_back(a[i]);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    ll len = v.size();
    for (ll i = 1; i <= n; i++)
    {
        insert(1, len, root[i - 1], root[i], getid(a[i]));
    }
    ll l, r, k;
    while (m--)
    {
        cin >> l >> r >> k;
        cout << v[query(1, len, root[l - 1], root[r], k) - 1] << endl;
    }
    getchar();
    getchar();
    return 0;
}
